﻿/*  ----------------------------------------------------------------------------
 *  DES-Release 2
 *  ----------------------------------------------------------------------------
 *  File:       ExecutionServer.cs
 *  Author:     nitinkoshy@gmail.com
 *  Source:     http://des.codeplex.com/
 *  ----------------------------------------------------------------------------
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DES.Common;

namespace DES.Server.Common
{
    public class ExecutionServer
    {
        private ExecutionManager _executionManager;
        private List<ExecutionServer> ConnectedServers { get; set; }
        private int MaxLoad { get; set; }
        private int CurrentLoad { get; set; }

        public string EndPoint { get; set; }
        public string Name { get; set; }

        public bool QueueTask(ClientTask clientTask)
        {
            //when the client asks for a task to be queued, dont check
            //the load queue it anyway.
            return true;
        }

        public bool QueueTask(ServerTask serverTask)
        {
            //first check the load
            //then check the capability of this server to execute this task
            //if yes, queue and then return true
            return true;
        }

        /// <summary>
        /// Called by an execution server onto parent server
        /// when the task has been completed
        /// </summary>
        /// <param name="serverTask"></param>
        public void SetProcessedTask(ServerTask serverTask)
        {
            //identify if the task was actually forwarded
            //if so, pop the server list
            //call the parent SetProcessedTask
        }

        public void ForwardTask(ServerTask serverTask, ExecutionServer server)
        {
            //forard the task to the mentioned server by calling
            //its QueueTask
        }
    }
}
